package MyDFS;

public class Leetcode0091 {

    public static int cnt = 0;
    public static int numDecodings(String s) {
        int len = s.length();
        if(len <= 0 || s.charAt(0)=='0'){
            return 0;
        }
        dfs(s, len, 0);
        return cnt;
    }

    public static boolean isA(char a, char b){
        int ans = (a - '0') * 10 + b - '0';
        return ans <= 26;
    }

    public static void dfs(String s, int len, int cur){
        System.out.println(cur + " " + cnt);
        if(cur==len){
            cnt++;
            System.out.println(cnt);
            return;
        }
        if(s.charAt(cur) == '0'){
            return;
        }
        dfs(s, len, cur+1);
        if(cur <= len-2 && isA(s.charAt(cur), s.charAt(cur+1))){
            dfs(s, len, cur+2);
        }
    }
    public static void main(String[] args) {
        String ss = "0";
        System.out.println(numDecodings(ss));
    }
}
